<?php
namespace jy_weishop\page;
defined('BY_JYA') or exit('error');
/*
	页面返回
*/
class order_list extends \plugin{
	public function getmain($return=array()){
		global $_RQ;
		$shopset=$this->plugin_setting('shopset');
		if($_RQ['gopayaddpriceid']){
			$return['gopayaddpriceid']=intval($_RQ['gopayaddpriceid']);
		}
		//返回链接
		$return['forward_url']=base64_encode('jy_weishop/order.list//fromcreate=1');
		$isfollow=pdo_getcolumn('core_fans',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'follow');	
		if(!$isfollow && $_RQ['fromcreate'] && !$shopset['noshowqrcode']){
			$return['showwechatcode']=1;
		}
		$return['fromcreate']=intval($_RQ['fromcreate']);
		if($return['fromcreate']){
			$neworder=pdo_get('jy_weishop_order',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'','id desc');	
			if($neworder['merchid'] && $this->plugin_exists('jy_merch')){
				$return['redfee']=pdo_getcolumn('jy_merch_feelog',array('createtime >'=>TIMESTAMP-10,'type'=>0,'merchid'=>$neworder['merchid'],'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'fee');	
				if($return['redfee']>0){
					$jy_merch=plugin('jy_merch')->plugin_setting('setting');
					$return['fanred_mp3']=$jy_merch['fanred_mp3'];
				}
			}
		}
		$return['sale_tan']=model('jy_weishop/activity/sales')->gettan(3);
		$return['list']=array();
		$return['status']=isset($_RQ['status'])?$_RQ['status']:100;
		$return['params']['status']=$return['status'];
		if($return['pc_set']['is_en']==1){
			set_html('title','Order list');
		}else{
			set_html('title','订单列表');
		}
		$return['tmplIds']=array();
		$return['feemoney']=$this->plugin_setting('feemoney');
		if($this->plugin_exists('jy_merch')){
			$return['merchred']=model('jy_merch/model')->get_nowred();
		}
		//$return['merchred']=3.00;
		if($return['merchred']>0){
			$return['merchredmp3']=plugin('jy_merch')->plugin_setting('setting')['red_mps'];
		}
		if(!$return['merchred']){
			$return['coupon_wait']=$this->model('task')->pop_coupon_wait();
			$return['coupon_wait']=$return['coupon_wait']?$return['coupon_wait'][0]:false;
		}
		if(!$return['merchred'] && !$return['coupon_wait']){
				$return['coupon_hd']=$this->model('task')->pop_coupon_hd();
				if(!$return['coupon_hd']){
					$return['game_wait']=$this->model('task')->pop_game();
				}
		}
		$return['member']=model('core/member')->detail($_SESSION['uid'],array('mobile','avatar','nickname'));
		return $return;
	}
}